﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using WepApi07.Data.Entity;

namespace WebApi07.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class WeatherForecastController : ControllerBase
    {
        private static readonly string[] Summaries = new[]
        {
            "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
        };

        private readonly ILogger<WeatherForecastController> _logger;

        public WeatherForecastController(ILogger<WeatherForecastController> logger)
        {
            _logger = logger;
        }

        [HttpGet]
        public IEnumerable<WeatherForecast> Get()
        {
            Student student = new Student();

            //var res = student.PrintStudent();

            var stu1 = new Student();

            var stu2 = new Student();

            Animals animals = new Animals();
            animals.PrintStudent();

            throw new Exception("错误:error desc");

            

            //return (IEnumerable<WeatherForecast>)NotFound("没有操作权限");


            var rng = new Random();
            return Enumerable.Range(1, 5).Select(index => new WeatherForecast
            {
                Date = DateTime.Now.AddDays(index),
                TemperatureC = rng.Next(-20, 55),
                Summary = Summaries[rng.Next(Summaries.Length)]
            })
            .ToArray();
        }
    }

    public class Student
    {
        public string StudentName { get; set; }
        public string PrintOk()
        {
            return this.StudentName;
        }
    }

    public class Animals
    {

    }

    public static class StudentHelper
    {
        public static string PrintStudent(this Animals stu)
        {
            return "美国英短";
        }
    }
    
}
